<template>
  <div>
    <i-frame :src="url" />
  </div>
</template>

<script>
import iFrame from "@/components/iFrame/index"
import { mapGetters } from "vuex";

export default {
  name: '',
  components: { iFrame },
  props: {},
  data() {
    return {
      url: ''
    }
  },
  filters: {},
  watch: {},
  computed: {
    ...mapGetters(["sidebarRouters"]),
  },
  created() {},
  mounted() {
    let str = this.$route.path.split('/')[this.$route.path.split('/').length - 1]
    let arr = this.flatten(this.sidebarRouters)
    arr.forEach(item => {
      if(item.path === str) {
        this.url = item.meta.link
        console.log(this.url)
      }
    })
  },
  beforeDestroy() {},
  methods: {
    setIframeHeight(iframe) {
      let iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow
      if (iframeWin.document.getElementById('viewer')) {
        iframe.height = iframeWin.document.getElementById('viewer').scrollHeight
      }
    },
    flatten(arr) {
      var res = [];
      arr.map((item) => {
        if (Array.isArray(item.children)) {
          res = res.concat(this.flatten(item.children));
        }
        res.push(item);
      });
      return res;
    },
  }
}
</script>

<style scoped lang="less">
</style>
